package com.zrrd.fuxi._02_set;

import java.util.*;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo01
 * @description
 * @create 2023/11/19 14:17
 */
public class Demo01 {
    public static void main(String[] args) {
        /*
        LinkedList
        ArrayList

        HashSet
        TreeSet
        LinkedHashSet

        HashMap
        TreeMap
        LinkedHashMap


        迭代器

        比较器

         */
        List<String> list=new ArrayList<>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add("赵六");
        list.add("钱七");

        System.out.println("------------------------------------------------");
        for (String s : list) {
            System.out.println(s);
        }

        System.out.println("------------------------------------------------");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

        System.out.println("------------------------------------------------");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }


        System.out.println("------------------------------------------------");
        //Lambda表达式
        list.forEach(System.out::println);


        System.out.println("------------------------------------------------");
        list.forEach(s -> System.out.println(s));


        System.out.println("------------------------------------------------");
        ListIterator<String> stringListIterator = list.listIterator();
        while (stringListIterator.hasNext()){
            System.out.println(stringListIterator.next());
        }
    }


}








